#ifndef __LEVELITEM_H__
#define __LEVELITEM_H__
#include "cocos2d.h"
#include "../GameScene.h"
#include "../util.h"
USING_NS_CC;
namespace suta
{
	class LevelItem:public CCLayer
	{
		int m_iLevel;
	public:
		bool init(int level,bool enabled);
		LAYER_NODE_FUNC_PARAM_2(LevelItem,int,level,bool,enabled);

		virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
		{
			CCPoint p=CCDirector::sharedDirector()->convertToGL(pTouch->locationInView());
			return ((p.x>=getPositionX()-getContentSize().width/2)&&(p.x<=getPositionX()+getContentSize().width/2)&&(p.y>=getPositionY()-getContentSize().height/2)&&(p.y<=getPositionY()+getContentSize().height/2));
		};
		virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
		{
			CCScene*scene=GameScene::node(m_iLevel);
			CCDirector::sharedDirector()->replaceScene(scene);
		};
		virtual void registerWithTouchDispatcher()
		{
			CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this,0,true);
		};
	};
}//namespace suta

#endif//__LEVELITEM_H__